﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



using System.Data;
#if MYSQL
using MySql.Data.MySqlClient;
#endif
namespace AFCEPF.BankApplication.DAL
{
    public class MySqlDbAccessor : AbstractDbAccessor
    {
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="mappedObject">The mapped object.</param>
        public MySqlDbAccessor(string connectionString, DataMapper mappedObject)
            : base(connectionString, mappedObject)
        {
            // On instancie le bon type de générateur SQL
            // pour ce DbAccessor..
            _sqlGenerator = new MySqlSqlGenerator(mappedObject);
        
        }

        #if MYSQL

        /// <summary>
        /// Inits the strongly-typed db objects
        /// (for Sql Server, or My Sql).
        /// </summary>
        protected override void initTypedDbObjects()
        {
            Connection  = newConnection();
            Command     = newCommand();
            Adapter     = new MySqlDataAdapter();
        }

        protected override IDbConnection newConnection()
        {
            return new MySqlConnection();
        }

        protected override IDbCommand newCommand()
        {
            return new MySqlCommand();
        }
    #else

        /// <summary>
        /// Inits the strongly-typed db objects
        /// (for Sql Server, or My Sql).
        /// </summary>
        protected override void initTypedDbObjects()
        {
           
        }

        protected override IDbConnection newConnection()
        {
            //return new MySqlConnection();
            return null;
        }

        protected override IDbCommand newCommand()
        {
            //return new MySqlCommand();
            return null;
        }

    #endif
    }
}
